﻿using System.Web.Mvc;
using CodeContribBlog.Data;

namespace CodeContribBlog.Web.Mvc.Areas.Admin.Controllers
{
	[Authorize]
	public abstract class AdminController : Controller
	{
		private BlogContext _blogContext;

		public BlogContext BlogContext
		{
			get { return _blogContext ?? (_blogContext = new BlogContext(User.Id)); }
		}

		public new User User
		{
			get { return (User)HttpContext.Items["__User"]; }
		}

		protected override void OnActionExecuted(ActionExecutedContext filterContext)
		{
			base.OnActionExecuted(filterContext);

			ViewBag.User = User;
		}
	}
}